<%--
  Created by IntelliJ IDEA.
  User: XYC
  Date: 2015/7/22
  Time: 11:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ include file="/WEB-INF/jsp/component/common.jsp" %>
<link href="${dean}/css/insurance.css" rel="stylesheet" type="text/css">
<html>
<head>
</head>
<body>
<table class="insurance">
  <tr>
    <td colspan="3">
      <input type="checkbox" value="1"/>社会基本医疗保险
      <input id="medicalInsuranceNum" type="text" <%--data-dean-decide="0"--%>data-dean-defultView="请输入医保卡号"  value="" class="card"/>
    </td>
  </tr>
  <tr>
    <td><input type="checkbox" value="2" />商业医疗保险</td>
    <td class="last"><input type="checkbox" value="3" />大病统筹</td>
    <td class="last"><input type="checkbox" value="4" />新型农村合作医疗</td>
  </tr>
  <tr>
    <td><input type="checkbox" value="5" />城镇居民基本医疗保险</td>
    <td class="last"><input type="checkbox" value="6" />公费医疗</td>
    <td class="last"><input type="checkbox" value="7" />铁路医保</td>
  </tr>
  <tr>
    <td><input type="checkbox" value="8" />贫困救助</td>
    <td class="last"><input type="checkbox" value="9" />全自费</td>
    <td class="last"><input type="checkbox" value="10" />其他</td>
  </tr>
</table>
<button class="store" onclick="saveData()">保存</button>
<%--<script type="text/javascript" src="${js}/jquery.min.js" charset="UTF-8"></script>--%>
<%--<script src="${js}/jquery.min.js"></script>--%>
<script src="${dean}/js/baseDell.js"></script>
<script src="${dean}/js/jquery-1.11.1.min.js"></script>
<script src="${dean}/js/insurance.js" type="text/javascript"></script>
<script src="${js}/dean.js" type="text/javascript"></script>
<script type="text/javascript">
  var insurance=${insurance};
  var medicalInsuranceNum = "${medicalInsuranceNum}";
  $(document).ready(function(){

    if(medicalInsuranceNum!=""){
      $(".insurance input[value='1']").prop('checked',true);
      $("#medicalInsuranceNum").val(medicalInsuranceNum);
    }

    var arrayTemp = insurance.insurance;

    var strs = arrayTemp.split("|");
    for(var i=0;i<strs.length-1;i++){
      $(".insurance input[value='"+strs[i]+"']").prop('checked',true)
    }

    BindClickWithInputShow(".insurance input[value='1']",".insurance input[type=text]","${dean}/img/card_bg");
    $(".insurance input[value=1]").click( function(){BindClickWithInputShow(".insurance input[value='1']",".insurance input[type=text]","${dean}/img/card_bg")});
    $(".insurance input[type=text]").focus(function(){textDefultShow(".insurance input[type=text]",true)});
    $(".insurance input[type=text]").blur(function(){textDefultShow(".insurance input[type=text]",false)});
  });


  function saveData(){
    var temp="";
    $(".insurance input[type=checkbox]:checked").each(function(){
//      alert($(this).val());
      temp = temp +$(this).val()+"|";
    });

    var data=new Object();
    data["idCard"]=insurance.idCard;
    data["insurance"]=temp;
    data["medicalInsuranceNum"]=$("#medicalInsuranceNum").val();

/*
    if(! $(".insurance input[value='1']").prop('checked')){

    }
*/

    jQuery.ajax({
      url :'${ctx}/web/patient/insurance/Set',
      type : "post",
      data:data,
      cache : false,
      dataType : "json",
      success : function(data){
        alert("提交完成");
      }
    });
//    alert(temp);
  }
</script>
</body>
</html>
